Promise.MyAllSettled = function (promises) {  // 无论如何都会成功返回状态，因此只有count == promises.length 就进行返回。
    let arr = [],  // 返回的是用数组保存的每一个promises结束后的状态以及val
        count = 0
    return new Promise((resolve, reject) => {
        promises.forEach((item, i) => {
            Promise.resolve(item).then(res => {
                arr[i] = { status: 'fulfilled', val: res }
                count += 1
                if (count === promises.length) resolve(arr)
            }, (err) => {
                arr[i] = { status: 'rejected', val: err }
                count += 1
                if (count === promises.length) resolve(arr)
            })
        })
    })
}

